package com.cxl.price.util;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Properties;
import com.summer.core.util.SysPath;

/**
 * @author wwwlike
 * TODO 
 */
public class PropertiesUtils {

    //private static Logger logger = Logger.getInstance();
    
    public static Properties load(String fileName) {
        Properties prop = new Properties();
        InputStream ini;
        try{
			ini = new FileInputStream(getPath()+"/"+fileName);
			prop.load(ini);
			ini.close();
		}catch(Exception e){
			e.printStackTrace();
		  //  Logger.getInstance().log("load properties file:"+fileName+" error!",e);
		}
        return prop;
    }
    
    public static boolean save(Properties prop,String fileName){
        boolean isOK = false;
        try{
            OutputStream out = new FileOutputStream(getPath()+"/"+fileName);
            prop.store(out,null);
            out.close();
            isOK = true;
        }catch(Exception e){
            isOK = false;
         //   Logger.getInstance().log("save properties file:"+fileName+" error!",e);
        }
        return isOK;
    }
    
    private static String getPath() {
		return SysPath.getPath();
	}
}
